
package ui.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.View;

import net.ck.hzq.R;

import java.util.ArrayList;
import java.util.List;

import base.BaseViewHolder;
import base.SuperBaseAdapter;
import dao.TradeRecordMerchantItem;
import ui.activity.profit.MerchantTradeAct;


/**
 * 交易明细字适配器
 * Created by chenjian on 19/2/27.
 */
public class TradeRecordChildAdapter extends SuperBaseAdapter<TradeRecordMerchantItem> {

    List<TradeRecordMerchantItem> mData = new ArrayList<>();
    Context mContext;
    String mMouth;

    public TradeRecordChildAdapter(Context context, List<TradeRecordMerchantItem> data,String month) {
        super(context, data);
        mContext = context;
        mData = data;
        mMouth=month;
    }

    @Override
    protected void convert(BaseViewHolder holder, final TradeRecordMerchantItem item, final int position) {
        holder.setText(R.id.merchant_name, item.getMerchantName()).setText(R.id.merchant_no, item.getMerchantNo())
                .setText(R.id.total_amount, item.getTradeTotal());
        if (position == mData.size() - 1) {
            holder.getView(R.id.view_line).setVisibility(View.GONE);
        } else {
            holder.getView(R.id.view_line).setVisibility(View.VISIBLE);
        }
        holder.getView(R.id.relative_layout).setOnClickListener(v -> {
            Intent intent = new Intent(mContext, MerchantTradeAct.class);
            intent.putExtra("month", mMouth);
            intent.putExtra("merchantNo", item.getMerchantNo());
            mContext.startActivity(intent);
        });
        holder.getView(R.id.iv_more).setOnClickListener(v -> {
            Intent intent = new Intent(mContext, MerchantTradeAct.class);
            intent.putExtra("month", mMouth);
            intent.putExtra("merchantNo", item.getMerchantNo());
            mContext.startActivity(intent);
        });
    }


    @Override
    protected int getItemViewLayoutId(int position, TradeRecordMerchantItem item) {
        return R.layout.item_trade_record_item;
    }

}
